import datetime

from django.db import models
# Create your models here.
from django.utils import timezone

from apps.firmUser.models import FirmUser
from apps.user.models import User

# 工作类别表
class JobCategory(models.Model):
    name = models.CharField(max_length=11,default="IT互联网",verbose_name="工作类别")

# 工作表
class jobs(models.Model):
    TYPE_CHOICES = (
        (1,"全职"),
        (2,"兼职"),
        (3,"自由")
    )
    jobs_name = models.CharField(max_length=28,verbose_name="工作名称")
    jobs_explain = models.TextField(verbose_name="工作说明")
    jobs_type = models.SmallIntegerField(choices=TYPE_CHOICES,default=1,verbose_name="工作类型")
    jobs_max_salary = models.CharField(max_length=6,verbose_name="最低薪资")
    jobs_min_salart = models.CharField(max_length=6,verbose_name="最高薪资")
    jobs_province = models.ForeignKey('areas.Area', on_delete=models.PROTECT, related_name='province_addresses',
                                 verbose_name='省')
    jobs_city = models.ForeignKey('areas.Area', on_delete=models.PROTECT, related_name='city_addresses', verbose_name='市')
    jobs_district = models.ForeignKey('areas.Area', on_delete=models.PROTECT, related_name='district_addresses',
                                 verbose_name='区')
    jobs_user = models.ForeignKey(FirmUser,on_delete=models.CASCADE,related_name='jobs',verbose_name="用户")
#     查看数
    look_count = models.CharField(max_length=11,verbose_name="查看次数",default='0')

#    收藏 多对对
    #redis
#    创建时间
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

#     工作类别
    jobs_categoty = models.ForeignKey(JobCategory,related_name='jobs',verbose_name="工作类别",on_delete=models.SET_NULL,null=True,default=1)

    jobs_require = models.TextField(verbose_name="任职要求",default="有上进心-有积极学习的能力")

    class Meta:
        verbose_name = '工作'
        verbose_name_plural = verbose_name

# 用户收藏工作表
class UserJobsCollect(models.Model):

    user = models.ForeignKey(User,related_name='collect',verbose_name='收藏的工作',on_delete=models.CASCADE)
    job = models.ForeignKey(jobs,related_name='collect',verbose_name="收藏工作的人",on_delete=models.CASCADE)









